<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>地址管理</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
">
    <link rel="stylesheet" th:href="@{/wxui/lib/weui.min.css}">
    <link rel="stylesheet" th:href="@{/wxui/css/jquery-weui.css}">
    <link rel="stylesheet" th:href="@{/wxui/css/style.css}">
</head>
<body ontouchstart>
<!--主体-->
<header class="wy-header">
    <div class="wy-header-icon-back"><span></span></div>
    <div class="wy-header-title">地址管理</div>
</header>
<div class="weui-content">
    <div class="weui-panel address-box">
        <div class="weui-panel__bd" th:each="item,itemStat:${address}">
            <div class="weui-media-box weui-media-box_text address-list-box">
                <a href="/receiveAddress/frontStage/goUpdateAddressPage?id=" th:href="@{'/receiveAddress/frontStage/goUpdateAddressPage?id='+${item.id}}" class="address-edit"></a>
                <h4 class="weui-media-box__title"><a th:addressId="${item.id}" th:orderId="${orderId}" class="selectAddress" th:text="${item.receivePersonName}"></a><span
                        th:text="${item.receivePersonPhone}"></span></h4>
                <p class="weui-media-box__desc address-txt selectAddress" th:addressId="${item.id}" th:orderId="${orderId}"  th:text="${item.province+item.city+item.area+item.address}">
                </p>
                <span class="default-add" style="background-color: #EA869A;margin-top: 10px;" th:text="${item.isDefault==1?'默认地址':null}"></span>
            </div>
        </div>
        <div class="weui-btn-area">
            <a class="weui-btn weui-btn_primary" style="background-color: #EA869A;" href="/receiveAddress/frontStage/goAddAddressPage"
               id="showTooltips">添加收货地址</a>
        </div>
    </div>
</div>

<script th:src="@{/wxui/lib/jquery-2.1.4.js}"></script>
<script th:src="@{/wxui/lib/fastclick.js}"></script>
<script type="text/javascript" th:src="@{/wxui/js/jquery.Spinner.js}"></script>
<script th:src="@{/wxui/js/jquery-weui.js}"></script>
<script th:inline="javascript">
    $(function () {
        FastClick.attach(document.body);
        $(".wy-header-icon-back").click(function () {
            location.href='/orderInfo/frontStage/goOrderDetilPage?orderInfoId='+[[${orderId}]]
        });


        /**
         * 更换收货地址
         */
        $(".selectAddress").click(function () {
            var id = $(this).attr("orderId");
            var addressId = $(this).attr("addressId");
            $.confirm("确定更换订单收货地址?", function () {
                $.ajax({
                    url: "/orderInfo/frontStage/updateOrderAddress",
                    dataType: "json",
                    data: {
                        'id':id,
                        'addressId':addressId
                    },
                    type: "post",
                    success: function (data) {
                        if (data.code == 200) {
                            $.toast(data.msg),
                                setTimeout('self.location=document.referrer', 1000)
                        } else {
                            $.toast(data.msg)
                        }
                    }
                })
            }, function () {
                //取消操作
            });
        })
    });
</script>

</body>
</html>
